<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="range  radio select css样式," />





  <link rel="alternate" href="/atom.xml" title="OBKoro1's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2" />






<meta name="description" content="写在前面：之前踩坑css的时候，遇到滑轮，按钮，选择框这类型的东西，为了页面效果，总是需要自定义他们的样式，而不使用他们的默认样式。当时写的时候，我也是蛮头疼的，弄了个demo，链接在下面。对此做个总结。本文是面向前端小白的，大手子可以跳过，写的不好之处多多见谅。 额，今天就先大概的将代码贴上来，考虑到篇幅的问题，就先写一下三个的实现方式，一般也都看得懂，代码注释的非常详细。因为细分下来内容也很多">
<meta name="keywords" content="range  radio select css样式">
<meta property="og:type" content="article">
<meta property="og:title" content="(干货)css自定义 range  radio select的样式滑轮，按钮，选择框">
<meta property="og:url" content="http://yoursite.com/2017/10/11/干货-css自定义-range-radio-select的样式滑轮，按钮，选择框/index.html">
<meta property="og:site_name" content="OBKoro1&#39;s Blog">
<meta property="og:description" content="写在前面：之前踩坑css的时候，遇到滑轮，按钮，选择框这类型的东西，为了页面效果，总是需要自定义他们的样式，而不使用他们的默认样式。当时写的时候，我也是蛮头疼的，弄了个demo，链接在下面。对此做个总结。本文是面向前端小白的，大手子可以跳过，写的不好之处多多见谅。 额，今天就先大概的将代码贴上来，考虑到篇幅的问题，就先写一下三个的实现方式，一般也都看得懂，代码注释的非常详细。因为细分下来内容也很多">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/a55ee3f7972d106aa085">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/e1a2344d909082c1646d">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/e34fb2c8622acdc68f79">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/8a473392afc4c904a8af">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/fddc27c19c39b6e3068b">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/5a226ede690f8b9a9a56">
<meta property="og:image" content="https://dn-mhke0kuv.qbox.me/bd148502090aea355bdd">
<meta property="og:updated_time" content="2019-06-15T06:19:47.656Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="(干货)css自定义 range  radio select的样式滑轮，按钮，选择框">
<meta name="twitter:description" content="写在前面：之前踩坑css的时候，遇到滑轮，按钮，选择框这类型的东西，为了页面效果，总是需要自定义他们的样式，而不使用他们的默认样式。当时写的时候，我也是蛮头疼的，弄了个demo，链接在下面。对此做个总结。本文是面向前端小白的，大手子可以跳过，写的不好之处多多见谅。 额，今天就先大概的将代码贴上来，考虑到篇幅的问题，就先写一下三个的实现方式，一般也都看得懂，代码注释的非常详细。因为细分下来内容也很多">
<meta name="twitter:image" content="https://dn-mhke0kuv.qbox.me/a55ee3f7972d106aa085">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/10/11/干货-css自定义-range-radio-select的样式滑轮，按钮，选择框/"/>





  <title>(干货)css自定义 range  radio select的样式滑轮，按钮，选择框 | OBKoro1's Blog</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?64d57d0b926bbd27431daa89d2e0a76b";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">OBKoro1's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-前端算法">
          <a href="/arithmetic/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            前端算法
          </a>
        </li>
      
        
        <li class="menu-item menu-item-博客最新更新">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            博客最新更新
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/10/11/干货-css自定义-range-radio-select的样式滑轮，按钮，选择框/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="OBKoro1">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/hand1.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="OBKoro1's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">(干货)css自定义 range  radio select的样式滑轮，按钮，选择框</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-10-11T22:32:54+08:00">
                2017-10-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/css/" itemprop="url" rel="index">
                    <span itemprop="name">css</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/10/11/干货-css自定义-range-radio-select的样式滑轮，按钮，选择框/" class="leancloud_visitors" data-flag-title="(干货)css自定义 range  radio select的样式滑轮，按钮，选择框">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1,534 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  6分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="写在前面："><a href="#写在前面：" class="headerlink" title="写在前面："></a>写在前面：</h2><p>之前踩坑css的时候，遇到滑轮，按钮，选择框这类型的东西，<strong>为了页面效果，总是需要自定义他们的样式</strong>，而不使用他们的默认样式。当时写的时候，我也是蛮头疼的，弄了个demo，链接在下面。对此做个总结。本文是<strong>面向前端小白</strong>的，大手子可以跳过，写的不好之处多多见谅。</p>
<p>额，今天就先大概的将代码贴上来，考虑到篇幅的问题，就先写一下三个的实现方式，一般也都看得懂，代码注释的非常详细。因为<strong>细分下来内容也很多</strong>，准备之后再将如何实现的方式，属性，优化以及如何兼容各个浏览器的方式一步步的写出来。</p>
<h3 id="最终效果："><a href="#最终效果：" class="headerlink" title="最终效果："></a>最终效果：</h3><p><img src="https://dn-mhke0kuv.qbox.me/a55ee3f7972d106aa085" alt="文章下面有demo链接"></p>
<h3 id="如何使用这些属性？"><a href="#如何使用这些属性？" class="headerlink" title="如何使用这些属性？"></a>如何使用这些属性？</h3><p>用法很简单，如下所示：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;input type=&quot;range&quot;&gt;//滑动条</span><br><span class="line">&lt;input type=&quot;radio&quot;&gt;//按钮</span><br><span class="line">&lt;select&gt;//选择框</span><br></pre></td></tr></table></figure>
<h2 id="input-type-”range”样式修改："><a href="#input-type-”range”样式修改：" class="headerlink" title="input type=”range”样式修改："></a>input type=”range”样式修改：</h2><p><img src="https://dn-mhke0kuv.qbox.me/e1a2344d909082c1646d" alt="滑块的默认样式"><br><img src="https://dn-mhke0kuv.qbox.me/e34fb2c8622acdc68f79" alt="滑块修改后的实现效果"></p>
<h3 id="html-content"><a href="#html-content" class="headerlink" title="html content"></a>html content</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;div&gt;</span><br><span class="line"> &lt;input type=&quot;range&quot; class=&quot;slider-block&quot; id=&quot;slider&quot; max=&quot;18&quot; min=&quot;6&quot; step=&quot;1&quot; value=&quot;6&quot;&gt;</span><br><span class="line">    &lt;!--主要是一个type=&quot;range&quot;属性,其他的会在细分的文章里面讲出来--&gt;</span><br><span class="line">&lt;/div&gt;</span><br></pre></td></tr></table></figure>
<h3 id="csscontent"><a href="#csscontent" class="headerlink" title="csscontent"></a>csscontent</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">.slider-block&#123;</span><br><span class="line">            outline: none; /*去掉点击时出现的外边框*/</span><br><span class="line">            -webkit-appearance: none;</span><br><span class="line">            -moz-appearance: none;</span><br><span class="line">            appearance: none; /*这三个是去掉那条线原有的默认样式，划重点！！*/</span><br><span class="line">            width: 30%;</span><br><span class="line">            height: 0.3rem;</span><br><span class="line">            background: orange; /*这三个是设置滑块下面那条线的样式*/</span><br><span class="line">        &#125;</span><br><span class="line">        input[type=&quot;range&quot;]::-webkit-slider-thumb &#123;</span><br><span class="line">            /*::-webkit-slider-thumb是代表给滑块的样式进行变更*/</span><br><span class="line">            -webkit-appearance: none;</span><br><span class="line">            -moz-appearance: none;</span><br><span class="line">            appearance: none; /*//这三个是去掉滑块原有的默认样式，划重点！！*/</span><br><span class="line">            -webkit-box-shadow:0 0 2px ;/*设置滑块的阴影*/</span><br><span class="line">            width: 2.6rem;</span><br><span class="line">            height:1.6rem;</span><br><span class="line">            background: url(&quot;images/js2-d_03.png&quot;);</span><br><span class="line">            background-size: cover; /*//这几个是设置滑块的样式*/</span><br><span class="line">        &#125;</span><br><span class="line">        //文章下面有demo链接</span><br></pre></td></tr></table></figure>
<h3 id="文章下面有demo链接"><a href="#文章下面有demo链接" class="headerlink" title="文章下面有demo链接"></a>文章下面有demo链接</h3><p>代码里面注释关键点都写了，还不能理解的，可以看下demo。</p>
<hr>
<h2 id="input-type-”radio”修改默认样式"><a href="#input-type-”radio”修改默认样式" class="headerlink" title="input type=”radio”修改默认样式"></a>input type=”radio”修改默认样式</h2><p><img src="https://dn-mhke0kuv.qbox.me/8a473392afc4c904a8af" alt="按钮的默认样式"><br><img src="https://dn-mhke0kuv.qbox.me/fddc27c19c39b6e3068b" alt="radio修改后的实现效果"></p>
<h3 id="html-content-1"><a href="#html-content-1" class="headerlink" title="html content"></a>html content</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&lt;form class=&quot;task10-main-box-shape&quot; method=&quot;post&quot; action=&quot;#&quot;&gt;</span><br><span class="line">    &lt;!--//表单元素基本上都要加form，传送的参数的方式，传递的位置，这是一个好习惯--&gt;</span><br><span class="line"></span><br><span class="line">&lt;div&gt;</span><br><span class="line">    &lt;input id=&quot;shape1&quot; name=&quot;box-shape&quot; type=&quot;radio&quot;  checked=&quot;checked&quot; value=&quot;shape1&quot; /&gt;</span><br><span class="line">    &lt;!--checked属性是当页面载入的时候选择这个按钮，value是传送的值--&gt;</span><br><span class="line">    &lt;label for=&quot;shape1&quot;&gt;对口箱&lt;/label&gt;&lt;!--/加label标签点击这个字的时候，可以选中按钮--&gt;</span><br><span class="line">&lt;/div&gt;</span><br><span class="line">&lt;/form&gt;</span><br></pre></td></tr></table></figure>
<h4 id="css样式这里相对难点，但我注释的已经很多了。"><a href="#css样式这里相对难点，但我注释的已经很多了。" class="headerlink" title="css样式这里相对难点，但我注释的已经很多了。"></a>css样式这里相对难点，但我注释的已经很多了。</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">.task10-main-box-shape input[type=&quot;radio&quot;]&#123;</span><br><span class="line">    display: none;</span><br><span class="line">    /*隐藏默认按钮的样式,这跟其他隐藏默认按钮的样式的方法不一样，注意一下*/</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">.task10-main-box-shape label&#123;  /*这里是设置文字的样式*/</span><br><span class="line">        display: inline-block;</span><br><span class="line">        cursor: pointer;</span><br><span class="line">        position: relative;</span><br><span class="line">        padding-left: 3rem;</span><br><span class="line">        margin-right: 6rem;</span><br><span class="line">        font-size: 1.8rem;</span><br><span class="line">        color: rgb(102,102,102);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    .task10-main-box-shape label:before &#123; /*这里是没被选中时候按钮的样式*/</span><br><span class="line">        content: &quot;&quot;;</span><br><span class="line">        /*将要自定义的东西设置为空的字符串，就可以往里面随意加定义的样式了*/</span><br><span class="line">        display: inline-block;</span><br><span class="line">        background-color: #FFFFFF; /*设置背景*/</span><br><span class="line">        padding:0.45em; /*撑开背景，就是中间那块白色的*/</span><br><span class="line">        border: 1px solid gray;</span><br><span class="line">        margin-right: 10px;</span><br><span class="line">        position: absolute;</span><br><span class="line">        left: 0;</span><br><span class="line">        bottom: 3px;</span><br><span class="line">        border-radius: 50%; /*设置圆角*/</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    input[type=radio]:checked + label:before &#123;/*按钮被选中之后的样式，多了一个checked*/</span><br><span class="line">        font-size: 1px;</span><br><span class="line">        color: #FFFFFF;</span><br><span class="line">        border:0.7rem solid rgb(29,122,217);</span><br><span class="line">        /*设置按钮样式*/</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="select修改默认样式"><a href="#select修改默认样式" class="headerlink" title="select修改默认样式"></a>select修改默认样式</h2><p><img src="https://dn-mhke0kuv.qbox.me/5a226ede690f8b9a9a56" alt="选择框的默认初始样式"><br><img src="https://dn-mhke0kuv.qbox.me/bd148502090aea355bdd" alt="select修改后的实现效果">### html cantent</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&lt;div&gt;</span><br><span class="line">    &lt;select class=&quot;task10-main-box-row2-select&quot;&gt;</span><br><span class="line">        &lt;option&gt;查看详情&lt;/option&gt;</span><br><span class="line">        &lt;option&gt;我也不知道&lt;/option&gt;</span><br><span class="line">        &lt;option&gt;详情是什么&lt;/option&gt;</span><br><span class="line">    &lt;/select&gt;</span><br><span class="line">&lt;/div&gt;</span><br></pre></td></tr></table></figure>
<h3 id="css-cantent"><a href="#css-cantent" class="headerlink" title="css cantent"></a>css cantent</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">.task10-main-box-row2-select&#123;</span><br><span class="line">        font-size: 1.6rem;</span><br><span class="line">        color: rgb(153,153,153);</span><br><span class="line">        padding: 0.3% 2% 0.3% 1%;</span><br><span class="line">        margin: 0; /*这里是选择框里面的样式*/</span><br><span class="line">        background: url(&quot;images/task10-d_03.png&quot;) no-repeat 97%;</span><br><span class="line">        /*97%是设置图片，也就是三角形的位置*/</span><br><span class="line">        background-size:20%; /*背景图片的尺寸*/</span><br><span class="line">        appearance:none;</span><br><span class="line">        -moz-appearance:none;</span><br><span class="line">        -webkit-appearance:none; /*这三个是隐藏默认样式*/</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<p>ps:css样式写的有点乱，各位看官，将就着看看，下面有demo链接。</p>
<hr>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>总的来说这类型的<strong>首先需要将样式隐藏掉，然后再自行添加需要的类型</strong>，但是有些隐藏样式的方式也不同，有些是这种，<code>appearance:none;
            -moz-appearance:none;
            -webkit-appearance:none;</code>像radio按钮的，反而是<code>display:none;</code>这种类型的。还有的样式可以写的很好看，比如滑块怎么移动的时候，填充条跟着移动。<strong>会的大家都会，要琢磨的精，会别人不会的，才是你身价所在。</strong></p>
<hr>
<h2 id="后话："><a href="#后话：" class="headerlink" title="后话："></a>后话：</h2><p>连续一个多星期不睡午觉，终于熬不住了。感觉身体被掏空，以后就改为下午的时候更文。因为一些事情耽搁了，直到晚上才弄好。下面几天会逐渐把这几个<strong>如何实现的方式，属性，优化以及如何兼容各个浏览器的方式</strong>一步步的写出来，链接会放在文末的。</p>
<p>假装这里有三个链接。<br><a href="https://juejin.im/post/58f2f43c61ff4b0058f4b5c5" target="_blank" rel="noopener">range滑块自定义样式，步骤详解以及实际应用</a></p>
<p><strong>最后：</strong>希望看完的朋友点个<strong>喜欢</strong>，也可以<strong>关注</strong>一下我，现在这阶段基本上每个月都不会少于十五篇文章（看到干货我也会进行分享）。码字不易，感谢支持，感激不尽！<br><strong>ps</strong>：目前待业，坐标北京，求推荐工作。然后希望我写哪方面的文章可以在底下评论，或者是私信我，虽然写的不好，但我就当这是记录自己成长的一种方式咯。（前提是我会了，如果不会我也会记下来，等会了的时候再更出来。）<br><a href="http://www.jianshu.com/u/8d1dd8c80f06" target="_blank" rel="noopener"></a><strong><a href="https://juejin.im/user/58714f0eb123db4a2eb95372" target="_blank" rel="noopener">掘金个人主页</a>  ，</strong><a href="http://www.jianshu.com/u/8d1dd8c80f06" target="_blank" rel="noopener"><strong>简书主页链接</strong></a>，<strong><a href="http://blog.csdn.net/OBKoro1?skin=dark1" target="_blank" rel="noopener">csdn博客主页链接</a> ，<a href="https://github.com/OBKoro1" target="_blank" rel="noopener">github</a> 。</strong></p>
<p>demo链接：<a href="https://obkoro1.github.io/article-demo/diy-style/diyStyle.html" target="_blank" rel="noopener">https://obkoro1.github.io/article-demo/diy-style/diyStyle.html</a></p>
<p>以上，2017.4.16.</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>听说，打赏我的人最后都找到了真爱。</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/pay/weixin.jpg" alt="OBKoro1 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/pay/ali.jpg" alt="OBKoro1 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/range-radio-select-css样式/" rel="tag"><i class="fa fa-tag"></i> range  radio select css样式</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/10/11/关于-CSS-的零碎知识点/" rel="next" title="关于 CSS 的零碎知识点">
                <i class="fa fa-chevron-left"></i> 关于 CSS 的零碎知识点
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/10/11/range滑块自定义样式，步骤详解以及实际应用/" rel="prev" title="range滑块自定义样式，步骤详解以及实际应用">
                range滑块自定义样式，步骤详解以及实际应用 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="/uploads/hand1.jpg"
              alt="OBKoro1" />
          
            <p class="site-author-name" itemprop="name">OBKoro1</p>
            <p class="site-description motion-element" itemprop="description">种一棵树最好的时间是十年前,其次是现在</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives">
            
                <span class="site-state-item-count">105</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">20</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">74</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/OBKoro1" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>GitHub</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://juejin.im/user/58714f0eb123db4a2eb95372" target="_blank" title="掘金">
                  
                    <i class="fa fa-fw fa-globe"></i>掘金</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://obkoro1.com/web_accumulate/" target="_blank" title="前端积累">
                  
                    <i class="fa fa-fw fa-globe"></i>前端积累</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://segmentfault.com/u/obkoro1/articles" target="_blank" title="segmentfault">
                  
                    <i class="fa fa-fw fa-globe"></i>segmentfault</a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#写在前面："><span class="nav-number">1.</span> <span class="nav-text">写在前面：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#最终效果："><span class="nav-number">1.1.</span> <span class="nav-text">最终效果：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#如何使用这些属性？"><span class="nav-number">1.2.</span> <span class="nav-text">如何使用这些属性？</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#input-type-”range”样式修改："><span class="nav-number">2.</span> <span class="nav-text">input type=”range”样式修改：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#html-content"><span class="nav-number">2.1.</span> <span class="nav-text">html content</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#csscontent"><span class="nav-number">2.2.</span> <span class="nav-text">csscontent</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#文章下面有demo链接"><span class="nav-number">2.3.</span> <span class="nav-text">文章下面有demo链接</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#input-type-”radio”修改默认样式"><span class="nav-number">3.</span> <span class="nav-text">input type=”radio”修改默认样式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#html-content-1"><span class="nav-number">3.1.</span> <span class="nav-text">html content</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#css样式这里相对难点，但我注释的已经很多了。"><span class="nav-number">3.1.1.</span> <span class="nav-text">css样式这里相对难点，但我注释的已经很多了。</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#select修改默认样式"><span class="nav-number">4.</span> <span class="nav-text">select修改默认样式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#css-cantent"><span class="nav-number">4.1.</span> <span class="nav-text">css cantent</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">5.</span> <span class="nav-text">总结</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#后话："><span class="nav-number">6.</span> <span class="nav-text">后话：</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2017 &mdash; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">OBKoro1</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">
      156.0k
    </span>
  
</div>




<div>
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span class="site-uv"><i class="fa fa-user"></i> 访问用户： <span class="busuanzi-value" id="busuanzi_value_site_uv">21621</span> 人 </span>
<span class="site-pv"><i class="fa fa-eye"></i> 访问次数： <span class="busuanzi-value" id="busuanzi_value_site_pv">68503</span> 次</span>

</div>



        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  








  



  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("9ANFp60h6oVyxIPGlau3NOA4-gzGzoHsz", "tMdNuKMbFtN4QsekeNVu83TV");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

  

  

</body>
</html>

